package Threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-03-10
 * Time: 19:57
 */


class MyThread  extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println("hello t");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    /*public void run2(){
        System.out.println("hello hhhh");
    }*/
    }
}
    public class demo1 {
        public static void main(String[] args)  {
            Thread t = new MyThread();//向上转型
             t.start();
            while(true){
                System.out.println("hello main");

                try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            /* t.run2()//这个方法是子类特有方法,不能通过父类调用*/

        }

    }
}
